package com.example.yuejian.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yuejian.Bean.Attention;
import com.example.yuejian.R;
import com.example.yuejian.UnitData;
import com.squareup.picasso.Picasso;

import java.util.List;


public class MyAttetionAdapter extends  RecyclerView.Adapter< RecyclerView.ViewHolder> {
    private Context mContext;
    private List<Attention.AttentiondataBean> mList;
    public LayoutInflater mLayoutInflater;

    public MyAttetionAdapter(Context mContext, List<Attention.AttentiondataBean> List) {
        this.mContext = mContext;
        this.mList = List;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_my_attention, parent, false);
        MyAttetionAdapter.ViewHolder v = new MyAttetionAdapter.ViewHolder(view);

        return v;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final Attention.AttentiondataBean club = (Attention.AttentiondataBean) mList.get(position);
        if (null == club)
            return;
        MyAttetionAdapter.ViewHolder viewHolder = (MyAttetionAdapter.ViewHolder) holder;
        viewHolder.name.setText(club.getName());
        if (club.getPic()!=null) {
            Picasso.with(mContext).load(UnitData.IMG_URL + club.getPic()).into(viewHolder.user_picture);
        }
    }



    @Override
    public int getItemCount() {
        return mList.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView name;
        ImageView user_picture;
        public ViewHolder(View itemView) {
            super(itemView);
            name = (TextView) itemView.findViewById(R.id.name);
            user_picture = (ImageView) itemView.findViewById(R.id.imgwwww);
        }
    }
}
